#region History

/* -------------------------------------------------------------------------------- 
 * Project Name: JobBoard Enterprise
 * Module: Jb.Web 
 * Name: PackageSubscription.cs
 * Purpose: ViewModel class for Package Subscription
 *                   
 * Author: Md. Hassanur Rahman
 * Language: C# SDK Version 4.0
 * --------------------------------------------------------------------------------
 * Change History:
 * Version: 1.0    MHR  07/17/2013
 * Description: Initial Development
 * -------------------------------------------------------------------------------- */

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Jb.Common.Extensions;


namespace Jb.Web.ViewModels
{
    [Serializable]
	public class PackageSubscriptionViewModel : BaseViewModel
	{	
        /// <summary>
		/// Gets or sets the ID
		/// </summary>
        public int ID { get; set;}

        [Required(ErrorMessage= "Please Select a Package")] 
        [Display(Name = "Package")] 
        public int PackageID { get; set;}
        
        [Required(ErrorMessage= "Please Select a Company")] 
        [Display(Name = "Company")] 
        public int CompanyID { get; set;}
            
        [Required(ErrorMessage= "Please Enter a Max Job Post")]
        [Display(Name = "Max Job Post")] 
		public int MaxJobPost	{ get; set; }
            
        [Required(ErrorMessage= "Please Enter a Max Resume Download")]
        [Display(Name = "Max Resume Download")] 
		public int MaxResumeDownload	{ get; set; }
            
        [Required(ErrorMessage= "Please Enter a Duration")]
        [Display(Name = "Duration")] 
		public int Duration	{ get; set; }
            
        [Required(ErrorMessage= "Please Enter a Subscribed On")]
        [Display(Name = "Subscribed On")] 
		public DateTime SubscribedOn	{ get; set; }
            
        [Required(ErrorMessage= "Please Choose Is Active?")]         
        [Display(Name = "Is Active")] 
		public bool IsActive	{ get; set; }
            
        [Display(Name = "Ref Sales Order")] 
		public int? RefSalesOrderID	{ get; set; }
            
        [Required(ErrorMessage= "Please Enter a Job Posted")]
        [Display(Name = "Job Posted")] 
		public int JobPosted	{ get; set; }
            
        [Required(ErrorMessage= "Please Enter a Resume Downloaded")]
        [Display(Name = "Resume Downloaded")] 
		public int ResumeDownloaded	{ get; set; }

        /// <summary>
        /// Returns a value indicating whether the user can post job with this subscription.
        /// </summary>
        public bool CanPostJob
        {
            get
            {
                if (this.HasExpired)
                    return false;

                if (this.MaxJobPost == -1 || this.JobPosted < this.MaxJobPost)
                    return true;
                return false;
            }
        }

        /// <summary>
        /// Returns a value indicating whether the user can download resume with this subscription.
        /// </summary>
        public bool CanDownloadResume
        {
            get
            {
                if (this.HasExpired)
                    return false;

                if (this.MaxResumeDownload == -1 || this.ResumeDownloaded < this.MaxResumeDownload)
                    return true;

                return false;
            }
        }

        /// <summary>
        /// Returns a value indicating whether this subscription has expired
        /// </summary>
        public bool HasExpired 
        {
            get
            {
                return this.SubscribedOn.AddDays(this.Duration) < DateTime.Now;
            }
        }
	}
}

